package com.tjsinfo.tjsoa.worklog.action;

import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.system.bo.ISystemUserBo;
import com.tjsinfo.tjsoa.system.vo.TSystemUser;
import com.tjsinfo.tjsoa.system.vo.User;
import com.tjsinfo.tjsoa.worklog.vo.WorkLogMain;


public class CheckDefalntWorkLogDateModleActionUp extends WorkLogDateModleUpAction{
	private ISystemUserBo userbo;

	public ISystemUserBo getUserbo() {
		return userbo;
	}

	public void setUserbo(ISystemUserBo userbo) {
		this.userbo = userbo;
	}	
	/* (non-Javadoc)
	 * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		
		User user = getDate(request);
		String datestr = getDateStr(request);
		Date date = getDateStr(datestr);
		
	
		request.setAttribute("userinfoid", user.getUser_id());
		
		Map<Date, WorkLogMain> map = workLogMainBo.selectWorkLogTypeAndYearMAPTimeStart("D", 1900+date.getYear(), user.getUser_id(),1);
		request.setAttribute("yueli", date);
		request.setAttribute("worklogmap", map);
		TSystemUser tjsuser = getDefinalutTjsuser(request, user);
		request.setAttribute("tjsuser", tjsuser);
		return mapping.findForward("ok");
	}
	
	protected User getDate(HttpServletRequest request) {
		Integer id  = Integer.parseInt(request.getParameter("userid"));
		User user = new User();
		user.setUser_id(id);
		return user;
	}
	protected TSystemUser getDefinalutTjsuser(HttpServletRequest request, User user) {
		TSystemUser  tjsuser= userbo.findByIdSystemUser(Integer.parseInt(request.getParameter("id")));
		user.setUser_id(Integer.parseInt(request.getParameter("id")));
		return tjsuser;
	}
}
